﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.EventEditViewModel>" %>
<%@ Import Namespace="SDT.Model" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Sự kiện
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
    Thêm mới sự kiện
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
        <%= Html.Toolbar("Quay về", "/Event", "back") %>
    </td>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    
    <% using (Html.BeginForm("Create", "Event", FormMethod.Post, new { id = "adminForm", enctype = "multipart/form-data" }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <div id="tabs">
    <ul>
		<li><a href="#tabs-1">Thông tin sự kiện</a></li>
		<li><a href="#tabs-2">Liên kết với chuyên mục bài viết</a></li>
	</ul>
	<div id="tabs-1">
    <table class="admintable" width="100%">
        <tbody>
            <tr>
                <td class="key">
                    Tên sự kiện (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBoxFor(model => model.Event.Title, new { style = "width:700px;", @class="required" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Ảnh đại diện
                </td>
                <td>
                    <input type="file" name="ArticleImage" id="ArticleImage" />
                </td>
            </tr>            
            <tr>
                <td class="key">
                    Trạng thái hiển thị
                </td>
                <td>
                    <%= Html.RadioButton("PubYN", true, new { @checked = "checked" })%>
                    Đăng sự kiện
                    <%= Html.RadioButton("PubYN", false)%>
                    Không sự kiện
                </td>
            </tr>
            <tr>
                <td class="key">
                    Đặt sự kiện trên trang chủ
                </td>
                <td>
                    <%= Html.RadioButton("HomeYN", true, new { @checked = "checked" })%>
                    Đăng sự kiện trên trang chủ
                    <%= Html.RadioButton("HomeYN", false)%>
                    Không đăng sự kiện trên trang chủ
                </td>
            </tr>            
            <tr>
                <td class="key">
                    Mô tả sự kiện
                </td>
                <td>
                    <%=Html.TextAreaFor(m=>m.Event.Description, new { cols = 97, rows = 25 })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Link liên kết
                </td>
                <td>
                    <%=Html.TextBoxFor(model => model.Event.Link, new {style="width:795px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    MetaDescription
                </td>
                <td>
                    <%=Html.TextBoxFor(model => model.Event.MetaDescription, new {style="width:795px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    MetaKeyword
                </td>
                <td>
                    <%=Html.TextBoxFor(model => model.Event.MetaKeyword, new {style="width:795px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    MetaTag
                </td>
                <td>
                    <%=Html.TextBoxFor(model => model.Event.MetaTag, new {style="width:795px" })%>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" id="btnSave" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                </td>
            </tr>
        </tbody>
    </table>
    </div>
    <div id="tabs-2">
        <ul style="margin:0;padding:0;list-style-type:none;">
		<% foreach( var item in Model.Categories) { %>
			<li><%= Html.CheckBox("ArticleCategory." + item.ID, false, new { value = item.ID, id = String.Format("ArticleCategory_{0}", item.ID) })%><%= item.Name %></li>
		<% } %>
		</ul>
    </div>
    </div>
    <%}
  } %>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#adminForm").validate();
            $("#tabs").tabs();
        });
        var fileIndex = 1;
        var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:':1 };
        function check_extension(filename, submitId) {
            var re = /\..+$/;
            var ext = filename.match(re).toString().toLowerCase();
            var submitEl = document.getElementById(submitId);
            if (hash[ext]) {
                submitEl.disabled = false;
                return true;
            } else {
            }
        };        
        tinyMCE.init({
            mode: "exact",
            elements: "Event_Description",
            theme: "advanced",
            plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
            theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            paste_use_dialog: false,
            paste_auto_cleanup_on_paste: true,
            paste_convert_headers_to_strong: false,
            paste_strip_class_attributes: "all",
            paste_remove_spans: true,
            paste_remove_styles: true
        });
    </script>

</asp:Content>
